<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
<title>省份信息查询</title>
<script type="text/javascript" src="../../js/jquery.min.js"></script>
<script type="text/javascript" src="../../js/jquery.pagination.js"></script>
<script type="text/javascript" src="../../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../../js/public.js"></script>
<script type="text/javascript" src="../../js/alert.js"></script>
<script type="text/javascript" src="../../js/loadSchoolGrade.js"></script>
<script type="text/javascript" src="../../js/jquery-ui/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css" href="../../js/jquery-ui/jquery-ui.css">
<link rel="stylesheet" type="text/css" href="../../css/bootstrap.css">
</head>
<body>
	<div>
		<form id="form1">
			<table class="table table-bordered .table-condensed">
				<tr>
					<td colspan="2"><label class="badge bg-blue">公告栏</label><input type="hidden" id="jsDeliverInfoid"  name="jsDeliverInfo.id" /></td>
				</tr>
				<tr>
					<td>发布的驾校：</td>
					<td>
						<input type="hidden" id="jsDeliverInfoSchoolid"  name="jsDeliverInfo.jsDrivingSchool.id" />
						<input type="hidden" readonly="readonly" id="jsDeliverInfoname"  name="jsDeliverInfo.jsDrivingSchool.name" />
						<div></div>
					</td>
				</tr>
				<tr>
					<td>公告:</td>
					<td><input type="text" id="jsDeliverInfo" name="jsDeliverInfo.deliverinfo" style="display: block;" /></td>
				</tr>
				
				<tr>
					<td colspan="4" style="text-align: center;">
						<button type="button" onclick="updateDeliverInfo();" class="btn btn-info">修改</button>
					</td>
				</tr>
			</table>
		</form>
	</div>
     
    <script type="text/javascript">
		var href = location.href.split("=");
		var infoId = href[1];
		getDeliverInfo(infoId);
		

    	//查看省份信息
    	function getDeliverInfo(id){
    		$.ajax({
    			url : "../../deliverInfo/get.ao",
    			type : 'POST',
    			data :{
    				"id" : id
    			},
    			cache : false,
    			beforeSend : ajaxstar,
    			complete : ajaxend,
    			dataType : "json",
    			success : function(data) {
    				if (data["state"] == "success") {
    					$("table").find("input").each(function(){//文本框内容
   							//获得Input文本框的name值，这个ID值 对应着Json数据中对象的值（PS：一个是大写一个小写 ） 
   							var a = $(this).attr("name");
   							if (a == null || typeof (a) == "undefined") {
   								return;
   							}
   							if (data["result"][0][a] == null || typeof (data["result"][0][a]) == "undefined") {
   								return;
   							}
   							if (a.indexOf("date") > -1) {
   								$(this).val(data["result"][0][a].split(" ")[0]);
   							} else if (a == "id" || a == "drivingschoolid") {
   								$(this).parent().find("a").each(function() {
   									if ($(this).attr("title") == data["result"][0][a]) {
   										$(this).click();
   									}
   								});
   							} else {
   								if (a == "id") {
   									$(this).parent().html('<input type="hidden" name="jsDeliverInfo.drivingschoolid" value="' + data["result"][0][a] + '"/>' + data["result"][0][a]);
   								}else if (a == "jsDeliverInfo.jsDrivingSchool.name"){
   									$(this).parent().find("div").html(data["result"][0][a]);
   									$(this).val(data["result"][0][a]);
   								} 
   								$(this).val(data["result"][0][a]);
   							}
    					});
    				} else {
    					sAlert(data["result"]);
    				}
    			}
    		});
    	}
    	
    	//修改省份
    	function updateDeliverInfo(){
    		if(confirm("确定修改吗?")){
				var id = $("#jsDeliverInfoid").val();
				var info = $("#jsDeliverInfo").val();
				$.ajax({
					url : "../../deliverInfo/getUp.ao",
					type : 'POST',
					data : {
						'id' : id,
						'info':info
					},
					beforeSend : ajaxstar,
					complete : ajaxend,
					cache : false,
					dataType : "json",
					success : function(data) {
						sAlert(data["result"]);
						if (data["state"] == "success") {
							location.reload();
						}
					}
				});
			}else{
				return;
			}	
    	}
    </script>
</body>
</html>